﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using ITM495.Lab2.Core;
using ITM495.Lab2.Core.Entities;
using System.Runtime.Serialization.Formatters.Binary;

namespace ITM495.Lab2.Impl.Writers
{
    public class BinaryWriter: IWriter<Tweet>
    {
        protected String Path { get; set; }

        public BinaryWriter(string path)
        {
            Path = path;
        }

        #region IWriter<Tweet> Members

        public void Write(IList<Tweet> entities)
        {
            var serializer = new BinaryFormatter();
            
            using(var binaryStream = new FileStream(Path, FileMode.Create))
            {
                serializer.Serialize(binaryStream, entities);
            }
        }

        #endregion
    }
}
